CFLAGS = -Wall -fpic -coverage -lm

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testdominion: dominion.o testdominion.c
	gcc -o testdominion testdominion.c -g dominion.o rngs.o $(CFLAGS)

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testBuyCard.c dominion.o rngs.o
	gcc -o testBuyCard -g  testBuyCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

all: playdom player testDrawCard testBuyCard badTestDrawCard

test1.out: unittest1.c dominion.c dominion.h dominion_helpers.h rngs.h 
	echo "Result for running unit tests:" > test1.out
	echo "unittest1.c:" >> test1.out
	gcc -o unittest1 dominion.c unittest1.c rngs.c -Wall -fpic -coverage -lm -std=c99
	unittest1 >> test1.out
	gcov dominion.c >> test1.out
test2.out: unittest1.c dominion.c dominion.h dominion_helpers.h rngs.h 
	echo "Result for running unit tests:" > test2.out
	echo "unittest3.c:" >> test2.out
	gcc -o unittest2 dominion.c unittest2.c rngs.c -Wall -fpic -coverage -lm -std=c99
	unittest2 >> test2.out
	gcov dominion.c >> test2.out
test3.out: unittest3.c dominion.c dominion.h dominion_helpers.h rngs.h 
	echo "Result for running unit tests:" > test3.out
	echo "unittest3.c:" >> test1.out
	gcc -o unittest3 dominion.c unittest3.c rngs.c -Wall -fpic -coverage -lm -std=c99
	unittest3 >> test3.out
	gcov dominion.c >> test3.out
test4.out: unittest4.c dominion.c dominion.h dominion_helpers.h rngs.h 
	echo "Result for running unit tests:" > test4.out
	echo "unittest4.c:" >> test4.out
	gcc -o unittest4 dominion.c unittest4.c rngs.c -Wall -fpic -coverage -lm -std=c99
	unittest4 >> test4.out
	gcov dominion.c >> test4.out
cardtest1.out: cardtest1.c dominion.c dominion.h dominion_helpers.h rngs.h 
	echo "Result for running unit tests:" > cardtest1.out
	echo "cardtest1.c:" >> cardtest1.out
	gcc -o cardtest1 dominion.c cardtest1.c rngs.c -Wall -fpic -coverage -lm -std=c99
	cardtest1 >> cardtest1.out
	gcov dominion.c >> cardtest1.out
cardtest2.out: cardtest2.c dominion.c dominion.h dominion_helpers.h rngs.h 
	echo "Result for running unit tests:" > cardtest2.out
	echo "cardtest2.c:" >> cardtest2.out
	gcc -o cardtest2 dominion.c cardtest2.c rngs.c -Wall -fpic -coverage -lm -std=c99
	cardtest2 >> cardtest2.out
	gcov dominion.c >> cardtest2.out
cardtest3.out: cardtest3.c dominion.c dominion.h dominion_helpers.h rngs.h
	echo "Result for running unit tests:" > cardtest3.out
	echo "cardtest3.c:" >> cardtest3.out
	gcc -o cardtest3 dominion.c cardtest3.c rngs.c -Wall -fpic -coverage -lm -std=c99
	cardtest3 >> cardtest3.out
	gcov dominion.c >> cardtest3.out
cardtest4.out: cardtest4.c dominion.c dominion.h dominion_helpers.h rngs.h
	echo "Result for running unit tests:" > test4.out
	echo "cardtest4.c:" >> cardtest4.out
	gcc -o cardtest4 dominion.c cardtest4.c rngs.c -Wall -fpic -coverage -lm -std=c99
	cardtest4 >> cardtest4.out
	gcov dominion.c >> cardtest4.out


unittestresults.out: unittest1.c unittest2.c unittest3.c unittest4.c cardtest1.c cardtest2.c cardtest3.c cardtest4.c dominion.c dominion.h dominion_helpers.h rngs.h
	echo "Results for running unittests:" > unittestresults.out
	echo "unittest1.c:" >> unittestresults.out
	gcc -o unittest1 dominion.c unittest1.c rngs.c -Wall -fpic -coverage -lm -std=c99
	unittest1 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out


	echo "unittest2.c:" >> unittestresults.out
	gcc -o unittest2 dominion.c unittest2.c rngs.c -Wall -fpic -coverage -lm -std=c99
	unittest2 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	

	echo "unittest3.c:" >> unittestresults.out
	gcc -o unittest3 dominion.c unittest3.c rngs.c -Wall -fpic -coverage -lm -std=c99
	unittest3 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	

	echo "unittest4.c:" >> unittestresults.out
	gcc -o unittest4 dominion.c unittest4.c rngs.c -Wall -fpic -coverage -lm -std=c99
	unittest4 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out


	echo "cardtest1.c:" >> unittestresults.out
	gcc -o cardtest1 dominion.c cardtest1.c rngs.c -Wall -fpic -coverage -lm -std=c99
	cardtest1 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out

	echo "cardtest2.c:" >> unittestresults.out
	gcc -o cardtest2 dominion.c cardtest2.c rngs.c -Wall -fpic -coverage -lm -std=c99
	cardtest2 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out

	echo "cardtest3.c:" >> unittestresults.out
	gcc -o cardtest3 dominion.c cardtest3.c rngs.c -Wall -fpic -coverage -lm -std=c99
	cardtest3 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out

	echo "cardtest4.c:" >> unittestresults.out
	gcc -o cardtest4 dominion.c cardtest4.c rngs.c -Wall -fpic -coverage -lm -std=c99
	cardtest4 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
randomtestadventurer.out: randomtestadventurer.c dominion.c dominion.h dominion_helpers.h rngs.h
	echo "Result for running unit tests:" > randomtestadventurer.out
	echo "randomtestadventurer.c:" >> randomtestadventurer.out
	gcc -o randomtestadventurer dominion.c randomtestadventurer.c rngs.c -Wall -fpic -coverage -lm -std=c99
	randomtestadventurer >> randomtestadventurer.out
randomtestcard.out: randomtestcard.c dominion.c dominion.h dominion_helpers.h rngs.h
	gcc -o randomtestcard dominion.c randomtestcard.c rngs.c -Wall -fpic -coverage -lm -std=c99
	randomtestcard >> randomtestcard.out
testdominion.out: testdominion.c dominion.c dominion.h dominion_helpers.h rngs.h
	echo "testdominion.out:" > testdominion.out
	gcc -o testdominion testdominion.c dominion.c rngs.c -Wall -fpic -coverage -lm -std=c99
	testdominion
	echo "Coverage for dominion.c:" >> testdominion.out
	gcov -bf dominion.c >> testdominion.out
	echo "Coverage for testdominion.c" >> testdominion.out
	gcov -bf testdominion.c >> testdominion.out
testCardFunctions.out: testCardFunctions.c dominion.c dominion.h dominion_helpers.h rngs.h
	echo "Results for testCardFunctions.c:" > testCardFunctions.out
	gcc -o testCardFunctions dominion.c testCardFunctions.c rngs.c -Wall -fpic -coverage -lm -std=c99
	testCardFunctions >> testCardFunctions.out
testCards.out: testCards.c testCards.h dominion.c dominion.h dominion_helpers.h rngs.h
	echo "Results for testCards.c:" > testCards.out
	gcc -o testCards dominion.c testCards.c rngs.c -Wall -fpic -coverage -lm -std=c99
	testCards >> testCards.out
systemtest.out: systemtest.c testCards2.c testCards.h dominion.c dominion.h dominion_helpers.h rngs.h
	echo "Results for systemtest.c:" > systemtest.out
	gcc -o systemtest systemtest.c dominion.c testCards2.c rngs.c -Wall -fpic -coverage -lm -std=c99
	systemtest >> systemtest.out
clean:
	rm -f *.o playdom.exe playdom test.exe test player player.exe testDrawCard testDrawCard.exe testBuyCard testBuyCard.exe badTestDrawCard badTestDrawCard.exe *.gcov *.gcda *.gcno *.so unitest1 unittest2 unitest3 unittest4 cardtest1 cardtest2 cardtest3 cardtest4 randomtestadventurer testdominion
